# CMakeLists.txt file for VTK4307
# copyright TU Delft Data Visualization Group
# Berkeley Licensing

#
# Set the project name.
#

PROJECT (VTK4307)

cmake_minimum_required(VERSION 2.4)
if(COMMAND cmake_policy)
    cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

#
# Assume everything is set up correctly for build.
#
# If some requirements are not met, set it to 0.
# In that case, the build won't be done.
#

SET (VTK4307_CAN_BUILD 1)

#
# Load CMake commands that you probably should not modify.
#

INCLUDE (${VTK4307_SOURCE_DIR}/CMakeOptions.cmake)

#
# If everything is OK, then go into the sub directories and build.
#

IF (VTK4307_CAN_BUILD)

  #
  # This is the list of kits available in VTK4307. Each kit corresponds to 
  # a sub-directory with the same name holding your local classes. Sorting 
  # classes by kit like VTK does (Common, Rendering, Filtering, Imaging, 
  # IO, etc.) is a good thing and prevents numerous dependencies problems.
  #

  # Core (non-optional kits)
  SET(VTK4307_KITS_CORE
    Graphics
    VolumeRendering
  )

  # Optional kits
  # Syntax: Dirname "Description"
  SET(VTK4307_KITS_OPTIONAL
  )

  #
  # --- You shouldn't need to modify anything below this line ---
  #

  # Keep lists of the kits built / not built in the current configuration
  SET(VTK4307_KITS_BUILT ${VTK4307_KITS_CORE})
  SET(VTK4307_KITS_NOTBUILT)

  # Process Core kits
  FOREACH(kit ${VTK4307_KITS_CORE})
    SUBDIRS(${kit})
    # Add it to the include dirs, otherwise building the wrappers may fail
    INCLUDE_DIRECTORIES(${VTK4307_SOURCE_DIR}/${kit})
  ENDFOREACH(kit)

  # Process optional kits
  LIST(LENGTH VTK4307_KITS_OPTIONAL nkits)
  IF(LENGTH) # we can only do this if there is at least 1 optional kit
  MATH(EXPR nkits "(${nkits} / 2) - 1" )
  FOREACH(i RANGE ${nkits})
    MATH(EXPR j "${i} * 2")
    MATH(EXPR k "${j} + 1")
    LIST(GET VTK4307_KITS_OPTIONAL ${j} kit)
    LIST(GET VTK4307_KITS_OPTIONAL ${k} kit_desc)
    STRING(TOUPPER ${kit} kit_uc)
    
    # Create an option for this kit and build it if selected
    OPTION(BUILD_${kit_uc} "${kit_desc}" OFF)
    IF (BUILD_${kit_uc})
      SUBDIRS(${kit})
      # Add it to the include dirs, otherwise building the wrappers may fail
      INCLUDE_DIRECTORIES(${VTK4307_SOURCE_DIR}/${kit})
      # Add to the list of kits built
      SET(VTK4307_KITS_BUILT ${VTK4307_KITS_BUILT} ${kit})
    ELSE (BUILD_${kit_uc})
      SET(VTK4307_KITS_NOTBUILT ${VTK4307_KITS_NOTBUILT} ${kit})
    ENDIF (BUILD_${kit_uc})
  ENDFOREACH(i)
  ENDIF(LENGTH)

  #
  # Build examples too ?
  #

  # uncomment when you start adding Examples!
  # OPTION(BUILD_EXAMPLES "Build examples." ON)
  # IF (BUILD_EXAMPLES)
  #   SUBDIRS(Examples)
  # ENDIF (BUILD_EXAMPLES)


  #
  # Build Utilities (Doxygen)
  #

  #SUBDIRS(Utilities)

  INCLUDE_DIRECTORIES(${VTK4307_BINARY_DIR})

  #
  # Generate files for using VTK4307 from another cmake project
  #

  SET(VTK4307_INCLUDE_DIRS_CONFIG "${VTK4307_SOURCE_DIR}")
  SET(VTK4307_LIBRARY_DIRS_CONFIG "${LIBRARY_OUTPUT_PATH}")
  SET(VTK4307_USE_FILE "${VTK4307_BINARY_DIR}/UseVTK4307.cmake")
  SET(VTK4307_KITS_FORCONFIG)
  FOREACH(kit ${VTK4307_KITS_BUILT})
    STRING(TOUPPER ${kit} kit_uc)
    SET(VTK4307_KITS_FORCONFIG ${VTK4307_KITS_FORCONFIG} ${kit_uc})
  ENDFOREACH(kit)
  CONFIGURE_FILE( 
    ${VTK4307_SOURCE_DIR}/UseVTK4307.cmake.in
    ${VTK4307_BINARY_DIR}/UseVTK4307.cmake
    COPYONLY IMMEDIATE
  )
  CONFIGURE_FILE(
    ${VTK4307_SOURCE_DIR}/VTK4307Config.cmake.in
    ${VTK4307_BINARY_DIR}/VTK4307Config.cmake
    @ONLY IMMEDIATE
  )

  #
  # Generate python import module
  #

  IF(VTK4307_WRAP_PYTHON)
    SET(VTK4307_KITS_FORPYTHON ${VTK4307_KITS_BUILT})
    CONFIGURE_FILE(
      "${VTK4307_SOURCE_DIR}/Wrapping/Python/vtk4307.py.in" 
      "${VTK4307_BINARY_DIR}/Wrapping/Python/vtk4307.py"
      @ONLY
    )
  ENDIF(VTK4307_WRAP_PYTHON)

  #
  # Disable deprecation warnings for standard C and STL functions in VS2005
  # and later
  #

  IF(CMAKE_COMPILER_2005)
    ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
    ADD_DEFINITIONS(-D_SCL_SECURE_NO_DEPRECATE)
  ENDIF(CMAKE_COMPILER_2005) 

ENDIF (VTK4307_CAN_BUILD)
